Public Class frmUtilitySettings

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub frmUtilitySettings_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            SetImageControl(Me)

            Me.Icon = System.Drawing.Icon.FromHandle(CType(mdiMain.imgMDIForm.Images(22), Bitmap).GetHicon())

            txtLocal.Text = GetRegistryValue("Data Source")
            txtNetwork.Text = GetRegistryValue("Network Data Source")

        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub btnOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOk.Click
        Try
            If Trim(txtLocal.Text) = "" Then
                MessageBox.Show("Specify local connection!", gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                txtLocal.Focus()
                Exit Sub
            ElseIf Trim(txtNetwork.Text) = "" Then
                MessageBox.Show("Specify network connection!", gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
                txtNetwork.Focus()
                Exit Sub
            End If

            SetRegistryValue("Data Source", txtLocal.Text)
            SetRegistryValue("Network Data Source", txtNetwork.Text)
            MessageBox.Show("Connection updated", gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Information)

            Me.Close()
        Catch ex As Exception
            MessageBox.Show(ex.Message, gstrMessage, MessageBoxButtons.OK, MessageBoxIcon.Error)
            AddErrorLog("Error " & Err.Number & " (" & Err.Description & ") in Procedure " & _
                Reflection.MethodBase.GetCurrentMethod.Name & " Of " & Me.Name)
        End Try
    End Sub

    Private Sub txtLocal_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtLocal.GotFocus
        txtLocal.SelectAll()
    End Sub

    Private Sub txtNetwork_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtNetwork.GotFocus
        txtNetwork.SelectAll()
    End Sub
End Class